package org.example.tlias.interceptor;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.example.tlias.utils.JwtUtils;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
@Slf4j
@Component
public class TokenInterceptor implements HandlerInterceptor {
//
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
////        String requestURI = request.getRequestURI();
////        if (requestURI.startsWith("/login")) {
////            log.info("登录请求");
////            return true;
////        }
//        String token = request.getHeader("token");
//        if (token == null || token.isEmpty()) {
//            log.info("token为空");
//            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
//            return false;
//        }
//        try {
//            JwtUtils.parseToken(token);
//        } catch (Exception e) {
//            log.info("token解析失败");
//            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
//            return false;
//        }
//
//        log.info("token验证成功");
//        return true;
//    }
}

















